<?php
include_once('model/photo.php');
$obj = new LZ_Photo;
$category_id = $_GET['cid'];

if (!$category_id)
{
	header("location:index.php");
	die;
}

include_once('model/photo_category.php');
$categoryobj = new LZ_Photo_Category;
$category = $categoryobj->get_one($category_id);


cache_this_page();
$total = $obj->get_list( array('select' => 'count(photo_id)','status' => 1,'category_id' => $category_id));
$total = $total[0]['count(photo_id)'];
$page = intval($_GET['page']);
$per_page = (intval($config['image_per_page']))?intval($config['image_per_page']):30;
!$page && $page=1;
$total_page = ceil($total/$per_page);
!$total_page && $total_page=1;
$page>$total_page && $page = $total_page;
$image_list = $obj->get_list( array('from' => ($page-1)*$per_page,'total'=>$per_page,'status' => 1,'category_id' => $category_id));

$pager = PAGER_TOTAL.$total.PAGER_ITEMS.' ';
$total_page > 1 && $pager.= $total_page.PAGER_PAGE;
$pager.= '<br />';
$pager.= html_pager("?cid=$category_id",$total_page,$page);

$_SESSION['last_list_page'] = "index.php?p=items&cid=$category_id&page=$page";
$view_data['page'] = $page;
$view_data['time'] = $time;
$view_data['pager'] = $pager;
$view_data['title'] = $category['name'].' '.$category['description'].' - '.S_PHOTO_LIST;
$view_data['image_list'] = $image_list;
$view_data['page_description'] = PUBLISHED_IMAGES.'->'.$category['name'];
$view_data['site_description'] = $category['description'];
$view_data['site_keywords'] = $category['name'];
include_once('left.php');
?>